Surface hosted tunnel conflict messages#19
Closed
mmkal wants to merge 3 commits into
Closed
Conversation
commit: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e0475ba. Configure here.
Contributor
Author
|
Superseded by #20, which is now the combined hosted safety PR with this conflict-message work included. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Rejected hosted tunnel connects now carry the Worker rejection reason through to library and CLI users. When an anonymous hosted tunnel name is already active under a different owner token,
createCaptunTunnelcan report the409 Conflictbody (Tunnel name is already connected) instead of onlyWebSocket connection failed, and the CLI treats that known Captun response as a name-in-use conflict rather than a DNS/certificate setup problem.Behavior
The CLI now follows that known conflict with guidance to pick a different
--nameor stop the existing anonymous client. Unrelated409responses keep the existing DNS/custom-domain troubleshooting path.Implementation Notes
Node’s WebSocket
ErrorEventdoes not expose the rejected upgrade response status/body directly. To make this deterministic for the hosted Worker conflict, the library performs a follow-upfetchto the same connect URL after a pre-open WebSocket failure and uses any non-2xx response body as rejection detail. That diagnostic probe has a short abort timeout and falls back to the generic WebSocket failure if the HTTP request does not answer.This works for the current Worker conflict path because the Worker returns
409before it attempts to create the WebSocket upgrade response. If another runtime/server fails the upgrade without returning an equivalent plain HTTP response to that follow-up request, the error remains the generic WebSocket failure.Verification
pnpm exec vitest run test/worker.test.ts test/cli.test.ts(first run hit a one-off Miniflare body-read flake, narrowed rerun and full rerun passed)pnpm run checkpnpm testpnpm run buildNote
Medium Risk
Changes tunnel connection error handling by probing failed WebSocket upgrades via HTTP and altering CLI messaging based on parsed rejection content; mistakes could misclassify failures or add minor latency on connect errors.
Overview
Improves tunnel connect failure reporting by adding
CaptunTunnelConnectErrorand, on pre-open WebSocket errors, doing a short-timeout HTTP probe of the connect URL to capture the server’s rejection status/body (e.g.409 Conflict: Tunnel name is already connected).Updates the CLI to detect this specific active-tunnel/name-in-use conflict and show actionable
--nameguidance instead of generic DNS/cert troubleshooting, while keeping the existing troubleshooting path for other failures.Adds Vitest coverage for the new rejection-surfacing behavior (including probe timeout fallback) and for the CLI’s conflict vs non-conflict messaging behavior.
Reviewed by Cursor Bugbot for commit 04328e3. Bugbot is set up for automated code reviews on this repo. Configure here.